package top.chj.day17.exam;

import org.junit.Test;

/**
 * @Auther:小陈的Java
 * 将一个字符串进行反转。将字符串中**指定部分**进行反转。比如abcdefg反转为abdcefg
 */
public class Test4 {
    @Test
    public void test(){
        String str="abcdefg";
        StringBuffer ss = new StringBuffer(str);
        System.out.println(ss);
        System.out.println(ss.reverse());
        String s1 =fz(str,2,4);
        System.out.println(s1);
    }

    public static String fz(String str,int begin,int end){
        String s1= str.substring(0,begin);
        String s2 = str.substring(begin,end);
        s2 = new StringBuffer(s2).reverse().toString();
        String s3 =str.substring(end);
        return s1+s2+s3;
    }
}